<?php

namespace app\common\model;

use think\Model;

class MemberPledgeLog extends Model
{
    protected $name = 'member_pledge_log';

    /**
     * 列表
     * @param $order
     * @param int $limit
     * @param int $page
     */
    public static function getList($limit = 20,$page = 1,$where=[],$order = 'id desc'){
        $data = self::where($where)->order($order)->paginate(['list_rows'=>$limit,'page'=>$page])->toArray();
        return $data;
    }

    /**
     * 查询所有
     * @param array $where 查询条件
     * @param string $order 排序
     * @return MiningPledge[]|array|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getAll($where = [],$order = 'id desc'){
        return self::where($where)->order($order)->select();
    }

    /**
     * 添加
     * @param $cid  代币ID
     * @param $release_cid  释放代币ID
     * @param $mid  用户ID
     * @param $money    参与金额
     * @param $type 1:参与 2:取出
     * @return int|string
     */
    public static function add($cid,$mid,$money,$type){
        $data = [
            'cid'   =>  $cid,
            'mid'   =>  $mid,
            'money'   =>  $money,
            'type'   =>  $type,
            'addtime'   =>  date('Y-m-d H:i:s',time())
        ];
        $id = self::insertGetId($data);
        return $id;
    }

}